package com.graduate.twentyone.controller;

import com.graduate.twentyone.common.R;
import com.graduate.twentyone.domain.RestDate;
import com.graduate.twentyone.domain.Valumes;
import com.graduate.twentyone.service.ValumesService;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Controller
@ResponseBody
@CrossOrigin
public class ValumesController {

    @Autowired
    ValumesService valumesService;

    //    查询当月的销售数据,返回食物名称，单价，销售数量
    @RequiresPermissions("admin:all")
    @GetMapping("/food/recentmonth")
    public R queryRecentMonth() {
        return R.ok().data("result", valumesService.queryRecentMonth());
    }

    //    查询分类销售数据，返回分类名称，销售数量，销售总额
    @RequiresPermissions("admin:all")
    @GetMapping("/food/salebycate")
    public R querySaleByCate() {
        return R.ok().data("result", valumesService.querySaleByCate());
    }

    @RequiresPermissions("admin:all")
    @RequestMapping(value = "sevenValume", method = RequestMethod.GET)

    public RestDate selectValumeofSeven() {
        List<Valumes> valumes = valumesService.SevenDayValume();

        RestDate restDate = new RestDate(200, "七天数据", valumes);


        return restDate;
    }
}
